<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/5/12
 * Time: 12:06
 */
include "MySqlConnect.php";
$mysqlconnect = new MySqlConnect();
$jieshou = $_REQUEST["jieshou"];
$openid = $_REQUEST["openid"];


if($jieshou=="checkopenid"){
	date_default_timezone_set('PRC');
//	$username = $_REQUEST["username"];
//	$headimg = $_REQUEST["headimg"];
//	$sex = $_REQUEST["sex"];
//	$city = $_REQUEST["city"];
	$nowtime = date('Y-m-d H:i:s');
	$mysqlconnect = new MySqlConnect();
	$querystr = "select * from user where openid='$openid'";
	$info =json_decode($mysqlconnect->GetDataSetJsonPHP($querystr)) ;
	$count = count($info);
	
//	$url="http://wx.qlogo.cn/mmopen/ajNVdqHZLLDdmymukmMwe0ncaichQQy9iaviavLXIbmtNlV9b8Xv6SKdwXv33n8uibTbEx0JFUnHwO0eCxpDlL8r7g/0";
//	$url="http://www.jkera.cn/xiadou/image/a19.png";
	
	if($count=="0")
	{
		echo 0;
	}
	else
	{
		echo $mysqlconnect->GetDataSetJsonPHP($querystr);
	}
	
}

if($jieshou=="AddUser"){
	date_default_timezone_set('PRC');
//	$username = $_REQUEST["username"];
//	$headimg = $_REQUEST["headimg"];
//	$sex = $_REQUEST["sex"];
//	$city = $_REQUEST["city"];
	$nowtime = date('Y-m-d H:i:s');
	$mysqlconnect = new MySqlConnect();
	$querystr = "select * from users where openid='$openid'";
	$info =json_decode($mysqlconnect->GetDataSetJsonPHP($querystr)) ;
	$count = count($info);
//	echo  $count;
	if($count=="0")
	{
		try
		{
			$jieguo = $mysqlconnect->ExecuteData("insert into users values(null,'$openid','','','$nowtime',0,0,0,'','',''");
		}
		catch(Exception $err){
			echo $err;
		}

//		echo "qin".$jieguo;
	}
//	echo $mysqlconnect->GetDataSetJsonPHP($querystr);
	
}
if($jieshou=="tijiao"){
	date_default_timezone_set('PRC');
	$xingming = $_REQUEST["xingming"];
	$shoujihao = $_REQUEST["shoujihao"];
	$nowtime = date('Y-m-d H:i:s');
	$mysqlconnect = new MySqlConnect();
	//$jieguo = $mysqlconnect->ExecuteData("update users set zimeiti='$zimeiti',chengshi='$chengshi',xingming='$xingming',lianxifangshi='$lianxifangshi' where openid='$openid'");
	$jieguo = $mysqlconnect->ExecuteData("update users set xingming='$xingming',shoujihao='$shoujihao' where openid='$openid'");
	echo "1";
//	echo $mysqlconnect->GetDataSetJsonPHP($querystr);
}
if($jieshou=="getzongchengji")
{
	echo $mysqlconnect->GetDataSetJson("select zuixinchengji from users where openid='$openid'");
	
}



?>
